package tuanda.soict.firstsun.PresentationPackage;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

public abstract class AbstractScreen implements Screen {

	protected final Stage stage;
	protected Skin skin;
	protected Object[] data;
	protected TalesOfTroubadour myGame;

	public AbstractScreen(Object[] inputData, TalesOfTroubadour game) {
		this.stage = new Stage(0, 0, true);
		skin = new Skin(Gdx.files.internal("Skin/uiskin.json"),
				Gdx.files.internal("Skin/uiskin.png"));
		data = inputData;
		setMyGame(game);
	}

	public Skin getSkin() {
		return this.skin;
	}

	@Override
	public void show() {
		Gdx.input.setInputProcessor(stage);
	}

	@Override
	public void resize(int width, int height) {
		stage.setViewport(width, height, true);
		stage.clear();
	}

	@Override
	public void render(float delta) {
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		stage.draw();
	}

	@Override
	public void hide() {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void dispose() {
		stage.dispose();
		if (skin != null) {
			skin.dispose();
		}
	}

	public TalesOfTroubadour getMyGame() {
		return myGame;
	}

	public void setMyGame(TalesOfTroubadour game) {
		this.myGame = game;
	}
}
